package com.cjh.weixin.controller;

import com.alibaba.fastjson.JSON;
import com.cjh.common.response.Result;
import com.cjh.common.service.EvaluateService;
import com.cjh.common.service.UploadService;
import com.cjh.common.wxDto.AddEvaluateDTO;
import com.cjh.weixin.common.handler.UserThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/evaluate")
public class EvaluateController {
    @Autowired
    UploadService uploadService;
    @Autowired
    EvaluateService evaluateService;
    @PostMapping("/uploadEvaluateImage")
    public Result upload(@RequestBody MultipartFile file){
        String s = uploadService.uploadFile(file, "evaluateImage/");
        return new Result().setCode(0).setMessage("上传成功！").setData(s);
    }

    @PostMapping("/addEvaluate")
    public Result addEvaluate(@RequestBody AddEvaluateDTO addEvaluateDTO){
        return evaluateService.addEvaluate(addEvaluateDTO);
    }

    @GetMapping("/getAllEvaluate")
    public Result getAllEvaluate(){
        return evaluateService.getAllEvaluate(UserThreadLocal.get().getId());
    }
}
